{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8b45ccfe",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'ing' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-2-e7a772e29a4d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m     17\u001b[0m     \u001b[1;34m'api_key'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;34m'HImHBFJ0cskTK9EDxBc6S5khzmD21c4u'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     18\u001b[0m     \u001b[1;34m'api_secret'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;34m'obThKs7n3roSjCVxQ4EGm-zum7WlKo5e'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 19\u001b[1;33m     \u001b[1;34m'image_base64'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0ming\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     20\u001b[0m     \u001b[1;34m'retrun_attributes'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;34m'gender,age,smiling,headpose,facequality,emotion,blur'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     21\u001b[0m }\n",
      "\u001b[1;31mNameError\u001b[0m: name 'ing' is not defined"
     ]
    }
   ],
   "source": [
    "\n",
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "Face++ 人脸检测\n",
    "'''\n",
    "\n",
    "request_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "# 二进制方式打开图片文件\n",
    "#1.图片文件准备\n",
    "f = open('cxk.jpg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "paylord = {\n",
    "    'api_key':'HImHBFJ0cskTK9EDxBc6S5khzmD21c4u',\n",
    "    'api_secret':'obThKs7n3roSjCVxQ4EGm-zum7WlKo5e',\n",
    "    'image_base64':ing,\n",
    "    'retrun_attributes':'gender,age,smiling,headpose,facequality,emotion,blur'\n",
    "}\n",
    "header = {'content_type':'application/x_www_form_urlencodeed'}\n",
    "response = requests.post(request_url,data = paylord,headers=headers)\n",
    "if response:\n",
    "    print (response.json())\n",
    "else:\n",
    "    print(response.status_code)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ea5ea6f9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f4dc1694",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
